 <template>
  <div>
    <div>
      <Activate :isActivate="activated" @to_activate="activate"></Activate>
      <el-row :gutter="20">
        <el-col :sm="24" :md="24" :lg="13">
          <Count></Count>
        </el-col>
        <el-col :sm="24" :md="24" :lg="11">
          <!-- 周数据统计 -->
          <sumDataChart></sumDataChart>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <!-- 课程排行榜 -->
        <el-col :sm="24" :md="24" :lg="13" :xl="13">
          <courseChart></courseChart>
        </el-col>
        <el-col :span="24" :md="24" :lg="11" :xl="11">
          <!-- 用户一周增长状况 -->
          <userChart></userChart>
        </el-col>
      </el-row>

      <Course></Course>
    </div>
  </div>
</template>

<script>
import Count from "./components/count.vue";
import Course from "./components/courseRank.vue";
import User from "./components/user.vue";
import sumDataChart from "./components/sumDataChart.vue";
import userChart from "./components/userChart.vue";
import courseChart from "./components/courseChart.vue";

import Activate from "src/components/activate/activate.vue";

import { mapState, mapMutations } from "vuex";
import { getSumMoney, getUser, getAccountCourse } from "src/service/count";

export default {
  data() {
    return {
      activated: false,
      sumData: {
        xAxis: [],
        seriesArr: []
      }
    };
  },
  components: {
    Count,
    Course,
    User,
    Activate,
    sumDataChart,
    userChart,
    courseChart
  },
  computed: {
    ...mapState(["userInfo"])
  },
  mounted() {
    // this.init();
    this.GET_USERINFO();
    this.activated = this.userInfo.activated; // 是否激活标识
  },
  methods: {
    ...mapMutations(["GET_USERINFO"]),
    activate() {
      this.$router.push("/profile");
    },
    init() {
      getSumMoney().then(res => {
        let xAxis = res.time,
          seriesArr = res.size;
        var data = [
          {
            name: "收入",
            type: "bar",
            barWidth: "25%",
            data: seriesArr,
            barGap: "10%"
          }
        ];
        this.sumData = {
          xAxis,
          seriesArr: seriesArr
        };
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "src/style/mixin";
</style>
